<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <button @click="fn">生成</button>
        <ul>
            <li v-for=" (v,i) in random">{{ v.num }}&nbsp;&nbsp;<button @click="del(i)">删除</button></li>
        </ul>
    </div>

    <script src="../vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                random: [
                    {
                        num: Math.round(Math.random() * 20)
                    }
                ]
            }, methods: {
                del(id) {
                    this.random.splice(id, 1)
                },
                fn() {
                    this.random.push({
                        num: Math.round(Math.random() * 20)
                    })
                }
            }
        })
    </script>
</body>

</html>